package ml.coursedesign.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ml.coursedesign.entity.CourseClass;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

/**
 * Mapper 接口
 *
 * @author likeqc.top
 * @since 2021-04-27
 */
public interface CourseClassMapper extends BaseMapper<CourseClass> {
    
    /**
     * 聚合查询课程信息（课程名，学时，学分，班级数，选课总人数，授课教师）
     * @param page
     * @return
     */
    @Select("SELECT cc.id, cc.`course_id`, cc.`classNum`, cc.`name`, cc.`teacher_id`, t.`nickname` teacherName FROM " +
            "course_class cc LEFT JOIN teacher t ON cc.`teacher_id` = t.`id` WHERE cc.`course_id` = #{courseId}")
    IPage<Map> getListByCourseId(Page page, @Param("courseId") Integer courseId);
}
